Test Series - java script

Test Number 80/92

Q: What does the interpreter do when you reference variables in other scopes?
A. Traverses the queue
B. Traverses the stack
C. Finds the bugs
D. Traverse the array
Solution: The interpreter executes the javascript code. Normally when you reference variables in other scopes at the global level, in other namespaces, and so on—the interpreter needs to traverse the stack to get to the variable.
Q: The attribute location belongs to which element?
A. document
B. html
C. image
D. pre
Solution: window.location.href returns the href (URL) of the current page. The attribute location belongs to the document element.
Q: What will happen if you reference document.location from within an object?
A. Traverses the queue
B. Finds the bugs
C. Traverses the stack
D. Traverses the array
Solution: window.location.href returns the href (URL) of the current page. If you reference document.location from within an object, the interpreter will need to go from the function that references the variable, up out of the namespace to the global window scope, down to the document scope, and gets the location value.
Q: Why do we need to create locally scoped variables to hold value?
A. To optimize the testing process
B. To increase the speed
C. To minimize memory usage
D. To cache the reference document.location
Solution: window.location.assign loads a new document. The locally scoped variables are created to cache the reference to document.location.
Q: What is the next step after calling the startTimeLogging()?
A. Interpret the code
B. Compile the code
C. Run the code
D. Debug the code
Solution: The startTimeLogging() method captures the timing data for ad hoc, etc for referencing an uncached document.location. Once the startTimeLogging() method is called, run the code to test.
Q: During the traversing through the stack, where does it go after it goes to the namespace?
A. Window
B. Function
C. Document
D. Location
Solution: Namespace in JavaScript is nothing but a single global object which will contain all our functions, methods, variables and all that. During the traversal in the stack manner, after going to the namespace, it goes to the Window.
Q: During the traversing through the stack, where does it go after it goes to the window?
A. Namespace
B. Function
C. Document
D. Nowhere
Solution: window.location.assign loads a new document. During the traversal in the stack manner, after going to the window, it goes nowhere.
Q: During the traversing of the stack when you create a locally scoped variable, where does it go after it goes to the namespace?
A. Window
B. Function
C. Document
D. Location
Solution: Namespace in JavaScript is nothing but a single global object which will contain all our functions, methods, variables and all that. When you create a locally scoped variable for caching the reference, the traversal reverses in the forward direction and thus, after going to the namespace, it goes to the function.
Q: What is the function used to stop capturing the ad hoc timing ?
A. stopadhoc()
B. stopTimer()
C. stopTimeLogging()
D. stophoc()
Solution: The startTimeLogging() method captures the timing data for ad hoc, etc for referencing an uncached document.location. In order to stop capturing the ad hoc timing for referencing uncached document.location, we call the method stopTimeLogging().
Q: During the traversing of the stack when you create a locally scoped variable, where does it go after it goes to the location?
A. Window
B. Function
C. Document
D. Nowhere
Solution: window.location.assign loads a new document. When you create a locally scoped variable for caching the reference, the traversal reverses in the forward direction and thus, after going to the location, it goes nowhere.

You Have Score    /10